package com.Jin.control;

import com.Jin.pojo.Employee;
import com.Jin.service.EmployeeSerivceImpl;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/Employee")
public class EmployeeController {

    @Autowired
    EmployeeSerivceImpl employeeSerivceimpl;

    //查询所有员工信息
    @RequestMapping("/getE")
    public List<Employee> queryEmployee(){
        List<Employee> employees = employeeSerivceimpl.queryEmployee();
        System.out.println(employees);
        return employees;
    }

    //查询员工通过id
    @RequestMapping("/getEbyId")
    public Employee queryEmployeeById(@RequestParam("Eid") int Eid){
        Employee employee = employeeSerivceimpl.queryById(Eid);
        System.out.println(Eid);
        System.out.println(employee);
        return employee;
    }

    //链接查询信息
    @RequestMapping("/getEbyUrl/{id}")
    public Employee queryByUrl(@PathVariable("id") int id){
        Employee employee = employeeSerivceimpl.queryByUrl(id);
        System.out.println(id);
        System.out.println(employee);
        return employee;
    }

}
